﻿Imports VSModel
Imports Cls_Common
Imports System.IO

Partial Class Control_Reports_TinhHinhThucHien
    Inherits System.Web.UI.UserControl
    Private Shared ReadOnly log As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
    Dim level As String = -1

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim script As ScriptManager = ScriptManager.GetCurrent(Me.Page)
            If Not script Is Nothing AndAlso script.IsInAsyncPostBack Then
                ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "regjs", "ajaxJquery()", True)
            Else
                Me.Page.ClientScript.RegisterStartupScript(Me.Page.GetType(), "regjs", String.Concat("Sys.Application.add_load(function(){", "ajaxJquery()", "});"), True)
            End If
            hidCurProvince.Value = Session("HuyenId")
        End If
    End Sub
#Region "Sub and Function"
    Private Sub BindToGrid(Optional ByVal dtmDateFrom As Date = #1/1/1900# _
                           , Optional ByVal dtmDateTo As Date = #12/31/3999# _
                           )
        Dim intHuyen As Integer = hidCurProvince.Value
        Using _data As New VSEntities
            Dim arrSearch() As String = {dtmDateFrom, dtmDateTo, intHuyen.ToString}
            ViewState("search") = arrSearch
        End Using
    End Sub
#End Region
    Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtTuNgayFrom.Text = ""
        txtToiNgayTo.Text = ""
    End Sub
    Protected Sub btnExportToExcel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnExportToExcel.Click
        Dim DateFrom As DateTime = IIf(txtTuNgayFrom.Text.Trim <> "", StringToDate(txtTuNgayFrom.Text.Trim), "1900/01/01")
        Dim DateTo As DateTime = IIf(txtToiNgayTo.Text.Trim <> "", StringToDate(txtToiNgayTo.Text.Trim), "3999/12/31")

        Dim intHuyen As Integer = hidCurProvince.Value
        BindToGrid(DateFrom, DateTo)
        Try

            Dim arrSearch() As String
            Dim _fieldName As String() = {"GiaTri"}
            arrSearch = ViewState("search")
            Using data As New VSEntities
                Dim _fileName As String = "ReportTinhHinhThucHien_" & Date.Now.ToFileTimeUtc()
                Dim p As List(Of uspCertifiedTinhHinhThucHien_Result) = data.uspCertifiedTinhHinhThucHien(DateFrom, DateTo, intHuyen).ToList
                Dim applicationPath As String = Server.MapPath(Request.ApplicationPath)
                If Not applicationPath.EndsWith("\") Then
                    applicationPath = applicationPath + "\"
                End If
                Dim licenseFile As String = Path.Combine(applicationPath, "bin\Aspose.Cells.lic")
                Dim license As Aspose.Cells.License = New Aspose.Cells.License()
                license.SetLicense(licenseFile)
                Dim _workbook As New Aspose.Cells.Workbook(Server.MapPath("~/Template/ReportTinhHinhThucHien.xls"))
                Dim _workSheet As Aspose.Cells.Worksheet = _workbook.Worksheets(0)

                '_workSheet.Cells.ImportCustomObjects(CType(p, System.Collections.ICollection), _fieldName, False, 9, 8, p.Count, True, "dd/MM/yyyy", False)
                'Adding a string value to the cell
                'huyện báo cáo
                Dim _Huyen = (From q In data.Provinces
                              Where q.Id = hidCurProvince.Value Select q.Title).FirstOrDefault
                If Not _Huyen Is Nothing Then
                    Dim _H = "UBND " & (_Huyen.ToUpper)
                    _workSheet.Cells("A1").PutValue(_H)
                End If
                'ngày xuất báo cáo
                'từ ngày
                Dim _dfYear As String = DateFrom.Year
                Dim _dfMonth As String = DateFrom.Month
                Dim _dfDay As String = DateFrom.Day
                'đến ngày
                Dim _dtYear As String = DateTo.Year
                Dim _dtMonth As String = DateTo.Month
                Dim _dtDay As String = DateTo.Day

                Dim _curNgay = "Từ ngày " & _dfDay & " Tháng " & _dfMonth & " năm " & _dfYear & " đến ngày " & _dtDay & " tháng " & _dtMonth & " năm " & _dtYear
                _workSheet.Cells("A7").PutValue(_curNgay)
                '=====================================================================
                'nong nghiep
                Dim _TTNongNghiep As String = (From q In p Where q.Ten = "TTNongNghiep" Select q.GiaTri).FirstOrDefault
                If _TTNongNghiep <> 0 And _TTNongNghiep <> "" Then
                    _workSheet.Cells("C14").PutValue(_TTNongNghiep)
                Else
                    _workSheet.Cells("C14").PutValue("0")
                End If
                Dim _TTVoNongNghiep As String = (From q In p Where q.Ten = "TTVoNongNghiep" Select q.GiaTri).FirstOrDefault
                If _TTVoNongNghiep <> 0 And _TTVoNongNghiep <> "" Then
                    _workSheet.Cells("C15").PutValue(CType(_TTVoNongNghiep / 1000000, Double))
                Else
                    _workSheet.Cells("C15").PutValue("0")
                End If
                'Dim _TTSoLaoDongNongNghiep As String = (From q In p Where q.Ten = "TTSoLaoDongNongNghiep" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongNongNghiep <> 0 And _TTSoLaoDongNongNghiep <> "" Then
                '    _workSheet.Cells("C16").PutValue(_TTSoLaoDongNongNghiep)
                'Else
                '    _workSheet.Cells("C16").PutValue("0")
                'End If
                Dim _TKNongNghiep As String = (From q In p Where q.Ten = "TKNongNghiep" Select q.GiaTri).FirstOrDefault
                If _TKNongNghiep <> 0 And _TKNongNghiep <> "" Then
                    _workSheet.Cells("C18").PutValue(_TKNongNghiep)
                Else
                    _workSheet.Cells("C18").PutValue("0")
                End If
                Dim _TKVoNongNghiep As String = (From q In p Where q.Ten = "TKVoNongNghiep" Select q.GiaTri).FirstOrDefault
                If _TKVoNongNghiep <> 0 And _TKVoNongNghiep <> "" Then
                    _workSheet.Cells("C19").PutValue(CType(_TKVoNongNghiep / 1000000, Double))
                Else
                    _workSheet.Cells("C19").PutValue("0")
                End If
                'Dim _TTKSoLaoDongNongNghiep As String = (From q In p Where q.Ten = "TKSoLaoDongNongNghiep" Select q.GiaTri).FirstOrDefault
                'If _TTKSoLaoDongNongNghiep <> 0 And _TTKSoLaoDongNongNghiep <> "" Then
                '    _workSheet.Cells("C20").PutValue(_TTKSoLaoDongNongNghiep)
                'Else
                '    _workSheet.Cells("C20").PutValue("0")
                'End If
                '=====================================================================
                'cong nghiep
                Dim _TTCongNghiep As String = (From q In p Where q.Ten = "TTCongNghiep" Select q.GiaTri).FirstOrDefault
                If _TTCongNghiep <> 0 And _TTCongNghiep <> "" Then
                    _workSheet.Cells("D14").PutValue(_TTCongNghiep)
                Else
                    _workSheet.Cells("D14").PutValue("0")
                End If
                Dim _TTVoCongNghiep As String = (From q In p Where q.Ten = "TTVoCongNghiep" Select q.GiaTri).FirstOrDefault
                If _TTVoCongNghiep <> 0 And _TTVoCongNghiep <> "" Then
                    _workSheet.Cells("D15").PutValue(CType(_TTVoCongNghiep / 1000000, Double))
                Else
                    _workSheet.Cells("D15").PutValue("0")
                End If
                'Dim _TTSoLaoDongCongNghiep As String = (From q In p Where q.Ten = "TTSoLaoDongCongNghiep" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongCongNghiep <> 0 And _TTSoLaoDongCongNghiep <> "" Then
                '    _workSheet.Cells("D16").PutValue(_TTSoLaoDongCongNghiep)
                'Else
                '    _workSheet.Cells("D16").PutValue("0")
                'End If
                Dim _TKCongNghiep As String = (From q In p Where q.Ten = "TKCongNghiep" Select q.GiaTri).FirstOrDefault
                If _TKCongNghiep <> 0 And _TKCongNghiep <> "" Then
                    _workSheet.Cells("D18").PutValue(_TKCongNghiep)
                Else
                    _workSheet.Cells("D18").PutValue("0")
                End If
                Dim _TKVoCongNghiep As String = (From q In p Where q.Ten = "TKVoCongNghiep" Select q.GiaTri).FirstOrDefault
                If _TKVoCongNghiep <> 0 And _TKVoCongNghiep <> "" Then
                    _workSheet.Cells("D19").PutValue(CType(_TKVoCongNghiep / 1000000, Double))
                Else
                    _workSheet.Cells("D19").PutValue("0")
                End If
                'Dim _TKSoLaoDongCongNghiep As String = (From q In p Where q.Ten = "TKSoLaoDongCongNghiep" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongCongNghiep <> 0 And _TKSoLaoDongCongNghiep <> "" Then
                '    _workSheet.Cells("D20").PutValue(_TKSoLaoDongCongNghiep)
                'Else
                '    _workSheet.Cells("D20").PutValue("0")
                'End If
                '=====================================================================
                'xay dung
                Dim _TTXayDung As String = (From q In p Where q.Ten = "TTXayDung" Select q.GiaTri).FirstOrDefault
                If _TTXayDung <> 0 And _TTXayDung <> "" Then
                    _workSheet.Cells("E14").PutValue(_TTXayDung)
                Else
                    _workSheet.Cells("E14").PutValue("0")
                End If
                Dim _TTVoXayDung As String = (From q In p Where q.Ten = "TTVoXayDung" Select q.GiaTri).FirstOrDefault
                If _TTVoXayDung <> 0 And _TTVoXayDung <> "" Then
                    _workSheet.Cells("E15").PutValue(CType(_TTVoXayDung / 1000000, Double))
                Else
                    _workSheet.Cells("E15").PutValue("0")
                End If
                'Dim _TTSoLaoDongXayDung As String = (From q In p Where q.Ten = "TTSoLaoDongXayDung" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongXayDung <> 0 And _TTSoLaoDongXayDung <> "" Then
                '    _workSheet.Cells("E16").PutValue(_TTSoLaoDongXayDung)
                'Else
                '    _workSheet.Cells("E16").PutValue("0")
                'End If
                Dim _TKXayDung As String = (From q In p Where q.Ten = "TKXayDung" Select q.GiaTri).FirstOrDefault
                If _TKXayDung <> 0 And _TKXayDung <> "" Then
                    _workSheet.Cells("E18").PutValue(_TKXayDung)
                Else
                    _workSheet.Cells("E18").PutValue("0")
                End If
                Dim _TKVoXayDung As String = (From q In p Where q.Ten = "TKVoXayDung" Select q.GiaTri).FirstOrDefault
                If _TKVoXayDung <> 0 And _TKVoXayDung <> "" Then
                    _workSheet.Cells("E19").PutValue(CType(_TKVoXayDung / 1000000, Double))
                Else
                    _workSheet.Cells("E19").PutValue("0")
                End If
                'Dim _TKSoLaoDongXayDung As String = (From q In p Where q.Ten = "TKSoLaoDongXayDung" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongXayDung <> 0 And _TKSoLaoDongXayDung <> "" Then
                '    _workSheet.Cells("E20").PutValue(_TKSoLaoDongXayDung)
                'Else
                '    _workSheet.Cells("E20").PutValue("0")
                'End If
                '=====================================================================
                'thuong mai dich vu
                Dim _TTThuongMaiDichVu As String = (From q In p Where q.Ten = "TTThuongMaiDichVu" Select q.GiaTri).FirstOrDefault
                If _TTThuongMaiDichVu <> 0 And _TTThuongMaiDichVu <> "" Then
                    _workSheet.Cells("F14").PutValue(_TTThuongMaiDichVu)
                Else
                    _workSheet.Cells("F14").PutValue("0")
                End If
                Dim _TTVoThuongMaiDichVu As String = (From q In p Where q.Ten = "TTVoThuongMaiDichVu" Select q.GiaTri).FirstOrDefault
                If _TTVoThuongMaiDichVu <> 0 And _TTVoThuongMaiDichVu <> "" Then
                    _workSheet.Cells("F15").PutValue(CType(_TTVoThuongMaiDichVu / 1000000, Double))
                Else
                    _workSheet.Cells("F15").PutValue("0")
                End If
                'Dim _TTSoLaoDongThuongMaiDichVu As String = (From q In p Where q.Ten = "TTSoLaoDongThuongMaiDichVu" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongThuongMaiDichVu <> 0 And _TTSoLaoDongThuongMaiDichVu <> "" Then
                '    _workSheet.Cells("F16").PutValue(_TTSoLaoDongThuongMaiDichVu)
                'Else
                '    _workSheet.Cells("F16").PutValue("0")
                'End If
                Dim _TKThuongMaiDichVu As String = (From q In p Where q.Ten = "TKThuongMaiDichVu" Select q.GiaTri).FirstOrDefault
                If _TKThuongMaiDichVu <> 0 And _TKThuongMaiDichVu <> "" Then
                    _workSheet.Cells("F18").PutValue(_TKThuongMaiDichVu)
                Else
                    _workSheet.Cells("F18").PutValue("0")
                End If
                Dim _TKVoThuongMaiDichVu As String = (From q In p Where q.Ten = "TKVoThuongMaiDichVu" Select q.GiaTri).FirstOrDefault
                If _TKVoThuongMaiDichVu <> 0 And _TKVoThuongMaiDichVu <> "" Then
                    _workSheet.Cells("F19").PutValue(CType(_TKVoThuongMaiDichVu / 1000000, Double))
                Else
                    _workSheet.Cells("F19").PutValue("0")
                End If
                'Dim _TKSoLaoDongThuongMaiDichVu As String = (From q In p Where q.Ten = "TKSoLaoDongThuongMaiDichVu" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongThuongMaiDichVu <> 0 And _TKSoLaoDongThuongMaiDichVu <> "" Then
                '    _workSheet.Cells("F20").PutValue(_TKSoLaoDongThuongMaiDichVu)
                'Else
                '    _workSheet.Cells("F20").PutValue("0")
                'End If
                '=====================================================================
                'tin dung
                Dim _TTTinDung As String = (From q In p Where q.Ten = "TTTinDung" Select q.GiaTri).FirstOrDefault
                If _TTTinDung <> 0 And _TTTinDung <> "" Then
                    _workSheet.Cells("G14").PutValue(_TTTinDung)
                Else
                    _workSheet.Cells("G14").PutValue("0")
                End If
                Dim _TTVoTinDung As String = (From q In p Where q.Ten = "TTVoTinDung" Select q.GiaTri).FirstOrDefault
                If _TTVoTinDung <> 0 And _TTVoTinDung <> "" Then
                    _workSheet.Cells("G15").PutValue(CType(_TTVoTinDung / 1000000, Double))
                Else
                    _workSheet.Cells("G15").PutValue("0")
                End If
                'Dim _TTSoLaoDongTinDung As String = (From q In p Where q.Ten = "TTSoLaoDongTinDung" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongTinDung <> 0 And _TTSoLaoDongTinDung <> "" Then
                '    _workSheet.Cells("G16").PutValue(_TTSoLaoDongTinDung)
                'Else
                '    _workSheet.Cells("G16").PutValue("0")
                'End If
                Dim _TKTinDung As String = (From q In p Where q.Ten = "TKTinDung" Select q.GiaTri).FirstOrDefault
                If _TKTinDung <> 0 And _TKTinDung <> "" Then
                    _workSheet.Cells("G18").PutValue(_TKTinDung)
                Else
                    _workSheet.Cells("G18").PutValue("0")
                End If
                Dim _TKVoTinDung As String = (From q In p Where q.Ten = "TKVoTinDung" Select q.GiaTri).FirstOrDefault
                If _TKVoTinDung <> 0 And _TKVoTinDung <> "" Then
                    _workSheet.Cells("G19").PutValue(CType(_TKVoTinDung / 1000000, Double))
                Else
                    _workSheet.Cells("G19").PutValue("0")
                End If
                'Dim _TKSoLaoDongTinDung As String = (From q In p Where q.Ten = "TKSoLaoDongTinDung" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongTinDung <> 0 And _TKSoLaoDongTinDung <> "" Then
                '    _workSheet.Cells("G20").PutValue(_TKSoLaoDongTinDung)
                'Else
                '    _workSheet.Cells("G20").PutValue("0")
                'End If
                '=====================================================================
                'thuy san
                Dim _TTThuySan As String = (From q In p Where q.Ten = "TTThuySan" Select q.GiaTri).FirstOrDefault
                If _TTThuySan <> 0 And _TTThuySan <> "" Then
                    _workSheet.Cells("H14").PutValue(_TTThuySan)
                Else
                    _workSheet.Cells("H14").PutValue("0")
                End If
                Dim _TTVoThuySan As String = (From q In p Where q.Ten = "TTVoThuySan" Select q.GiaTri).FirstOrDefault
                If _TTVoThuySan <> 0 And _TTVoThuySan <> "" Then
                    _workSheet.Cells("H15").PutValue(CType(_TTVoThuySan / 1000000, Double))
                Else
                    _workSheet.Cells("H15").PutValue("0")
                End If
                'Dim _TTSoLaoDongThuySan As String = (From q In p Where q.Ten = "TTSoLaoDongThuySan" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongThuySan <> 0 And _TTSoLaoDongThuySan <> "" Then
                '    _workSheet.Cells("H16").PutValue(_TTSoLaoDongThuySan)
                'Else
                '    _workSheet.Cells("H16").PutValue("0")
                'End If
                Dim _TKThuySan As String = (From q In p Where q.Ten = "TKThuySan" Select q.GiaTri).FirstOrDefault
                If _TKThuySan <> 0 And _TKThuySan <> "" Then
                    _workSheet.Cells("H18").PutValue(_TKThuySan)
                Else
                    _workSheet.Cells("H18").PutValue("0")
                End If
                Dim _TKVoThuySan As String = (From q In p Where q.Ten = "TKVoThuySan" Select q.GiaTri).FirstOrDefault
                If _TKVoThuySan <> 0 And _TKVoThuySan <> "" Then
                    _workSheet.Cells("H19").PutValue(CType(_TKVoThuySan / 1000000, Double))
                Else
                    _workSheet.Cells("H19").PutValue("0")
                End If
                'Dim _TKSoLaoDongThuySan As String = (From q In p Where q.Ten = "TKSoLaoDongThuySan" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongThuySan <> 0 And _TKSoLaoDongThuySan <> "" Then
                '    _workSheet.Cells("H20").PutValue(_TKSoLaoDongThuySan)
                'Else
                '    _workSheet.Cells("H20").PutValue("0")
                'End If
                '=====================================================================
                'van tai thong tin lien lac
                Dim _TTVanTaiThongTinLienLac As String = (From q In p Where q.Ten = "TTVanTaiThongTinLienLac" Select q.GiaTri).FirstOrDefault
                If _TTVanTaiThongTinLienLac <> 0 And _TTVanTaiThongTinLienLac <> "" Then
                    _workSheet.Cells("I14").PutValue(_TTVanTaiThongTinLienLac)
                Else
                    _workSheet.Cells("I14").PutValue("0")
                End If
                Dim _TTVoVanTaiThongTinLienLac As String = (From q In p Where q.Ten = "TTVoVanTaiThongTinLienLac" Select q.GiaTri).FirstOrDefault
                If _TTVoVanTaiThongTinLienLac <> 0 And _TTVoVanTaiThongTinLienLac <> "" Then
                    _workSheet.Cells("I15").PutValue(CType(_TTVoVanTaiThongTinLienLac / 1000000, Double))
                Else
                    _workSheet.Cells("I15").PutValue("0")
                End If
                'Dim _TTSoLaoDongVanTaiThongTinLienLac As String = (From q In p Where q.Ten = "TTSoLaoDongVanTaiThongTinLienLac" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongVanTaiThongTinLienLac <> 0 And _TTSoLaoDongVanTaiThongTinLienLac <> "" Then
                '    _workSheet.Cells("I16").PutValue(_TTSoLaoDongVanTaiThongTinLienLac)
                'Else
                '    _workSheet.Cells("I16").PutValue("0")
                'End If
                Dim _TKVanTaiThongTinLienLac As String = (From q In p Where q.Ten = "TKVanTaiThongTinLienLac" Select q.GiaTri).FirstOrDefault
                If _TKVanTaiThongTinLienLac <> 0 And _TKVanTaiThongTinLienLac <> "" Then
                    _workSheet.Cells("I18").PutValue(_TKVanTaiThongTinLienLac)
                Else
                    _workSheet.Cells("I18").PutValue("0")
                End If
                Dim _TKVoVanTaiThongTinLienLac As String = (From q In p Where q.Ten = "TKVoVanTaiThongTinLienLac" Select q.GiaTri).FirstOrDefault
                If _TKVoVanTaiThongTinLienLac <> 0 And _TKVoVanTaiThongTinLienLac <> "" Then
                    _workSheet.Cells("I19").PutValue(CType(_TKVoVanTaiThongTinLienLac / 1000000, Double))
                Else
                    _workSheet.Cells("I19").PutValue("0")
                End If
                'Dim _TKSoLaoDongVanTaiThongTinLienLac As String = (From q In p Where q.Ten = "TKSoLaoDongVanTaiThongTinLienLac" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongVanTaiThongTinLienLac <> 0 And _TKSoLaoDongVanTaiThongTinLienLac <> "" Then
                '    _workSheet.Cells("I20").PutValue(_TKSoLaoDongVanTaiThongTinLienLac)
                'Else
                '    _workSheet.Cells("I20").PutValue("0")
                'End If
                '=====================================================================
                'y tế
                Dim _TTYTe As String = (From q In p Where q.Ten = "TTYTe" Select q.GiaTri).FirstOrDefault
                If _TTYTe <> 0 And _TTYTe <> "" Then
                    _workSheet.Cells("J14").PutValue(_TTYTe)
                Else
                    _workSheet.Cells("J14").PutValue("0")
                End If
                Dim _TTVoYTe As String = (From q In p Where q.Ten = "TTVoYTe" Select q.GiaTri).FirstOrDefault
                If _TTVoYTe <> 0 And _TTVoYTe <> "" Then
                    _workSheet.Cells("J15").PutValue(CType(_TTVoYTe / 1000000, Double))
                Else
                    _workSheet.Cells("J15").PutValue("0")
                End If
                'Dim _TTSoLaoDongYTe As String = (From q In p Where q.Ten = "TTSoLaoDongYTe" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongYTe <> 0 And _TTSoLaoDongYTe <> "" Then
                '    _workSheet.Cells("J16").PutValue(_TTSoLaoDongYTe)
                'Else
                '    _workSheet.Cells("J16").PutValue("0")
                'End If
                Dim _TKYTe As String = (From q In p Where q.Ten = "TKYTe" Select q.GiaTri).FirstOrDefault
                If _TKYTe <> 0 And _TKYTe <> "" Then
                    _workSheet.Cells("J18").PutValue(_TKYTe)
                Else
                    _workSheet.Cells("J18").PutValue("0")
                End If
                Dim _TKVoYTe As String = (From q In p Where q.Ten = "TKVoYTe" Select q.GiaTri).FirstOrDefault
                If _TKVoYTe <> 0 And _TKVoYTe <> "" Then
                    _workSheet.Cells("J19").PutValue(CType(_TKVoYTe / 1000000, Double))
                Else
                    _workSheet.Cells("J19").PutValue("0")
                End If
                'Dim _TKSoLaoDongYTe As String = (From q In p Where q.Ten = "TKSoLaoDongYTe" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongYTe <> 0 And _TKSoLaoDongYTe <> "" Then
                '    _workSheet.Cells("J20").PutValue(_TKSoLaoDongYTe)
                'Else
                '    _workSheet.Cells("J20").PutValue("0")
                'End If
                '=====================================================================
                'dịch vụ cầm đồ
                Dim _TTDichVuCamDo As String = (From q In p Where q.Ten = "TTDichVuCamDo" Select q.GiaTri).FirstOrDefault
                If _TTDichVuCamDo <> 0 And _TTDichVuCamDo <> "" Then
                    _workSheet.Cells("K14").PutValue(_TTDichVuCamDo)
                Else
                    _workSheet.Cells("K14").PutValue("0")
                End If
                Dim _TTVoDichVuCamDo As String = (From q In p Where q.Ten = "TTVoDichVuCamDo" Select q.GiaTri).FirstOrDefault
                If _TTVoDichVuCamDo <> 0 And _TTVoDichVuCamDo <> "" Then
                    _workSheet.Cells("K15").PutValue(CType(_TTVoDichVuCamDo / 1000000, Double))
                Else
                    _workSheet.Cells("K15").PutValue("0")
                End If
                'Dim _TTSoLaoDongDichVuCamDo As String = (From q In p Where q.Ten = "TTSoLaoDongDichVuCamDo" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongDichVuCamDo <> 0 And _TTSoLaoDongDichVuCamDo <> "" Then
                '    _workSheet.Cells("K16").PutValue(_TTSoLaoDongDichVuCamDo)
                'Else
                '    _workSheet.Cells("K16").PutValue("0")
                'End If
                Dim _TKDichVuCamDo As String = (From q In p Where q.Ten = "TKDichVuCamDo" Select q.GiaTri).FirstOrDefault
                If _TKDichVuCamDo <> 0 And _TKDichVuCamDo <> "" Then
                    _workSheet.Cells("K18").PutValue(_TKDichVuCamDo)
                Else
                    _workSheet.Cells("K18").PutValue("0")
                End If
                Dim _TKVoDichVuCamDo As String = (From q In p Where q.Ten = "TKVoDichVuCamDo" Select q.GiaTri).FirstOrDefault
                If _TKVoDichVuCamDo <> 0 And _TKVoDichVuCamDo <> "" Then
                    _workSheet.Cells("K19").PutValue(CType(_TKVoDichVuCamDo / 1000000, Double))
                Else
                    _workSheet.Cells("K19").PutValue("0")
                End If
                'Dim _TKSoLaoDongDichVuCamDo As String = (From q In p Where q.Ten = "TKSoLaoDongDichVuCamDo" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongDichVuCamDo <> 0 And _TKSoLaoDongDichVuCamDo <> "" Then
                '    _workSheet.Cells("K20").PutValue(_TKSoLaoDongDichVuCamDo)
                'Else
                '    _workSheet.Cells("K20").PutValue("0")
                'End If
                '=====================================================================
                'thông tin liên lạc
                Dim _TTThongTinLienLac As String = (From q In p Where q.Ten = "TTThongTinLienLac" Select q.GiaTri).FirstOrDefault
                If _TTThongTinLienLac <> 0 And _TTThongTinLienLac <> "" Then
                    _workSheet.Cells("L14").PutValue(_TTThongTinLienLac)
                Else
                    _workSheet.Cells("L14").PutValue("0")
                End If
                Dim _TTVoThongTinLienLac As String = (From q In p Where q.Ten = "TTVoThongTinLienLac" Select q.GiaTri).FirstOrDefault
                If _TTVoThongTinLienLac <> 0 And _TTVoThongTinLienLac <> "" Then
                    _workSheet.Cells("L15").PutValue(CType(_TTVoThongTinLienLac / 1000000, Double))
                Else
                    _workSheet.Cells("L15").PutValue("0")
                End If
                'Dim _TTSoLaoDongThongTinLienLac As String = (From q In p Where q.Ten = "TTSoLaoDongThongTinLienLac" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongThongTinLienLac <> 0 And _TTSoLaoDongThongTinLienLac <> "" Then
                '    _workSheet.Cells("L16").PutValue(_TTSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("L16").PutValue("0")
                'End If
                Dim _TKThongTinLienLac As String = (From q In p Where q.Ten = "TKThongTinLienLac" Select q.GiaTri).FirstOrDefault
                If _TKThongTinLienLac <> 0 And _TKThongTinLienLac <> "" Then
                    _workSheet.Cells("L18").PutValue(_TKThongTinLienLac)
                Else
                    _workSheet.Cells("L18").PutValue("0")
                End If
                Dim _TKVoThongTinLienLac As String = (From q In p Where q.Ten = "TKVoThongTinLienLac" Select q.GiaTri).FirstOrDefault
                If _TKVoThongTinLienLac <> 0 And _TKVoThongTinLienLac <> "" Then
                    _workSheet.Cells("L19").PutValue(CType(_TKVoThongTinLienLac / 1000000, Double))
                Else
                    _workSheet.Cells("L19").PutValue("0")
                End If
                'Dim _TKSoLaoDongThongTinLienLac As String = (From q In p Where q.Ten = "TKSoLaoDongThongTinLienLac" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongThongTinLienLac <> 0 And _TKSoLaoDongThongTinLienLac <> "" Then
                '    _workSheet.Cells("L20").PutValue(_TKSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("L20").PutValue("0")
                'End If
                '=====================================================================
                'Nghệ thuật vui chơi giải trí
                Dim _TTNgheThuatVuiChoiGiaiTri As String = (From q In p Where q.Ten = "TTNgheThuatVuiChoiGiaiTri" Select q.GiaTri).FirstOrDefault
                If _TTNgheThuatVuiChoiGiaiTri <> 0 And _TTNgheThuatVuiChoiGiaiTri <> "" Then
                    _workSheet.Cells("M14").PutValue(_TTNgheThuatVuiChoiGiaiTri)
                Else
                    _workSheet.Cells("M14").PutValue("0")
                End If
                Dim _TTVoNgheThuatVuiChoiGiaiTri As String = (From q In p Where q.Ten = "TTVoNgheThuatVuiChoiGiaiTri" Select q.GiaTri).FirstOrDefault
                If _TTVoNgheThuatVuiChoiGiaiTri <> 0 And _TTVoNgheThuatVuiChoiGiaiTri <> "" Then
                    _workSheet.Cells("M15").PutValue(CType(_TTVoNgheThuatVuiChoiGiaiTri / 1000000, Double))
                Else
                    _workSheet.Cells("M15").PutValue("0")
                End If
                'Dim _TTSoLaoDongNgheThuatVuiChoiGiaiTri As String = (From q In p Where q.Ten = "TTSoLaoDongNgheThuatVuiChoiGiaiTri" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongNgheThuatVuiChoiGiaiTri <> 0 And _TTSoLaoDongNgheThuatVuiChoiGiaiTri <> "" Then
                '    _workSheet.Cells("M16").PutValue(_TTSoLaoDongNgheThuatVuiChoiGiaiTri)
                'Else
                '    _workSheet.Cells("M16").PutValue("0")
                'End If
                Dim _TKNgheThuatVuiChoiGiaiTri As String = (From q In p Where q.Ten = "TKNgheThuatVuiChoiGiaiTri" Select q.GiaTri).FirstOrDefault
                If _TKNgheThuatVuiChoiGiaiTri <> 0 And _TKNgheThuatVuiChoiGiaiTri <> "" Then
                    _workSheet.Cells("M18").PutValue(_TKNgheThuatVuiChoiGiaiTri)
                Else
                    _workSheet.Cells("M18").PutValue("0")
                End If
                Dim _TKVoNgheThuatVuiChoiGiaiTri As String = (From q In p Where q.Ten = "TKVoNgheThuatVuiChoiGiaiTri" Select q.GiaTri).FirstOrDefault
                If _TKVoNgheThuatVuiChoiGiaiTri <> 0 And _TKVoNgheThuatVuiChoiGiaiTri <> "" Then
                    _workSheet.Cells("M19").PutValue(CType(_TKVoNgheThuatVuiChoiGiaiTri / 1000000, Double))
                Else
                    _workSheet.Cells("M19").PutValue("0")
                End If
                'Dim _TKSoLaoDongNgheThuatVuiChoiGiaiTri As String = (From q In p Where q.Ten = "TKSoLaoDongNgheThuatVuiChoiGiaiTri" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongNgheThuatVuiChoiGiaiTri <> 0 And _TKSoLaoDongNgheThuatVuiChoiGiaiTri <> "" Then
                '    _workSheet.Cells("M20").PutValue(_TKSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("M20").PutValue("0")
                'End If
                '=====================================================================
                'Giáo dục và đào tạo
                Dim _TTGiaoDucDaoTao As String = (From q In p Where q.Ten = "TTGiaoDucDaoTao" Select q.GiaTri).FirstOrDefault
                If _TTGiaoDucDaoTao <> 0 And _TTGiaoDucDaoTao <> "" Then
                    _workSheet.Cells("N14").PutValue(_TTGiaoDucDaoTao)
                Else
                    _workSheet.Cells("N14").PutValue("0")
                End If
                Dim _TTVoGiaoDucDaoTao As String = (From q In p Where q.Ten = "TTVoGiaoDucDaoTao" Select q.GiaTri).FirstOrDefault
                If _TTVoGiaoDucDaoTao <> 0 And _TTVoGiaoDucDaoTao <> "" Then
                    _workSheet.Cells("N15").PutValue(CType(_TTVoGiaoDucDaoTao / 1000000, Double))
                Else
                    _workSheet.Cells("N15").PutValue("0")
                End If
                'Dim _TTSoLaoDongGiaoDucDaoTao As String = (From q In p Where q.Ten = "TTSoLaoDongGiaoDucDaoTao" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongGiaoDucDaoTao <> 0 And _TTSoLaoDongGiaoDucDaoTao <> "" Then
                '    _workSheet.Cells("N16").PutValue(_TTSoLaoDongGiaoDucDaoTao)
                'Else
                '    _workSheet.Cells("N16").PutValue("0")
                'End If
                Dim _TKGiaoDucDaoTao As String = (From q In p Where q.Ten = "TKGiaoDucDaoTao" Select q.GiaTri).FirstOrDefault
                If _TKGiaoDucDaoTao <> 0 And _TKGiaoDucDaoTao <> "" Then
                    _workSheet.Cells("N18").PutValue(_TKGiaoDucDaoTao)
                Else
                    _workSheet.Cells("N18").PutValue("0")
                End If
                Dim _TKVoGiaoDucDaoTao As String = (From q In p Where q.Ten = "TKVoGiaoDucDaoTao" Select q.GiaTri).FirstOrDefault
                If _TKVoGiaoDucDaoTao <> 0 And _TKVoGiaoDucDaoTao <> "" Then
                    _workSheet.Cells("N19").PutValue(CType(_TKVoGiaoDucDaoTao / 1000000, Double))
                Else
                    _workSheet.Cells("N19").PutValue("0")
                End If
                'Dim _TKSoLaoDongGiaoDucDaoTao As String = (From q In p Where q.Ten = "TKSoLaoDongGiaoDucDaoTao" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongGiaoDucDaoTao <> 0 And _TKSoLaoDongGiaoDucDaoTao <> "" Then
                '    _workSheet.Cells("N20").PutValue(_TKSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("N20").PutValue("0")
                'End If
                '=====================================================================
                'Dịch vụ
                Dim _TTDichVu As String = (From q In p Where q.Ten = "TTDichVu" Select q.GiaTri).FirstOrDefault
                If _TTDichVu <> 0 And _TTDichVu <> "" Then
                    _workSheet.Cells("O14").PutValue(_TTDichVu)
                Else
                    _workSheet.Cells("O14").PutValue("0")
                End If
                Dim _TTVoDichVu As String = (From q In p Where q.Ten = "TTVoDichVu" Select q.GiaTri).FirstOrDefault
                If _TTVoDichVu <> 0 And _TTVoDichVu <> "" Then
                    _workSheet.Cells("O15").PutValue(CType(_TTVoDichVu / 1000000, Double))
                Else
                    _workSheet.Cells("O15").PutValue("0")
                End If
                'Dim _TTSoLaoDongDichVu As String = (From q In p Where q.Ten = "TTSoLaoDongDichVu" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongDichVu <> 0 And _TTSoLaoDongDichVu <> "" Then
                '    _workSheet.Cells("O16").PutValue(_TTSoLaoDongDichVu)
                'Else
                '    _workSheet.Cells("O16").PutValue("0")
                'End If
                Dim _TKDichVu As String = (From q In p Where q.Ten = "TKDichVu" Select q.GiaTri).FirstOrDefault
                If _TKDichVu <> 0 And _TKDichVu <> "" Then
                    _workSheet.Cells("O18").PutValue(_TKDichVu)
                Else
                    _workSheet.Cells("O18").PutValue("0")
                End If
                Dim _TKVoDichVu As String = (From q In p Where q.Ten = "TKVoDichVu" Select q.GiaTri).FirstOrDefault
                If _TKVoDichVu <> 0 And _TKVoDichVu <> "" Then
                    _workSheet.Cells("O19").PutValue(CType(_TKVoDichVu / 1000000, Double))
                Else
                    _workSheet.Cells("O19").PutValue("0")
                End If
                'Dim _TKSoLaoDongDichVu As String = (From q In p Where q.Ten = "TKSoLaoDongDichVu" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongDichVu <> 0 And _TKSoLaoDongDichVu <> "" Then
                '    _workSheet.Cells("O20").PutValue(_TKSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("O20").PutValue("0")
                'End If
                '=====================================================================
                'Nhà hàng khách sạn
                Dim _TTKhachSanNhaHang As String = (From q In p Where q.Ten = "TTKhachSanNhaHang" Select q.GiaTri).FirstOrDefault
                If _TTKhachSanNhaHang <> 0 And _TTKhachSanNhaHang <> "" Then
                    _workSheet.Cells("P14").PutValue(_TTKhachSanNhaHang)
                Else
                    _workSheet.Cells("P14").PutValue("0")
                End If
                Dim _TTVoKhachSanNhaHang As String = (From q In p Where q.Ten = "TTVoKhachSanNhaHang" Select q.GiaTri).FirstOrDefault
                If _TTVoKhachSanNhaHang <> 0 And _TTVoKhachSanNhaHang <> "" Then
                    _workSheet.Cells("P15").PutValue(CType(_TTVoKhachSanNhaHang / 1000000, Double))
                Else
                    _workSheet.Cells("P15").PutValue("0")
                End If
                'Dim _TTSoLaoDongKhachSanNhaHang As String = (From q In p Where q.Ten = "TTSoLaoDongKhachSanNhaHang" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongKhachSanNhaHang <> 0 And _TTSoLaoDongKhachSanNhaHang <> "" Then
                '    _workSheet.Cells("P16").PutValue(_TTSoLaoDongKhachSanNhaHang)
                'Else
                '    _workSheet.Cells("P16").PutValue("0")
                'End If
                Dim _TKKhachSanNhaHang As String = (From q In p Where q.Ten = "TKKhachSanNhaHang" Select q.GiaTri).FirstOrDefault
                If _TKKhachSanNhaHang <> 0 And _TKKhachSanNhaHang <> "" Then
                    _workSheet.Cells("P18").PutValue(_TKKhachSanNhaHang)
                Else
                    _workSheet.Cells("P18").PutValue("0")
                End If
                Dim _TKVoKhachSanNhaHang As String = (From q In p Where q.Ten = "TKVoKhachSanNhaHang" Select q.GiaTri).FirstOrDefault
                If _TKVoKhachSanNhaHang <> 0 And _TKVoKhachSanNhaHang <> "" Then
                    _workSheet.Cells("P19").PutValue(CType(_TKVoKhachSanNhaHang / 1000000, Double))
                Else
                    _workSheet.Cells("P19").PutValue("0")
                End If
                'Dim _TKSoLaoDongKhachSanNhaHang As String = (From q In p Where q.Ten = "TKSoLaoDongKhachSanNhaHang" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongKhachSanNhaHang <> 0 And _TKSoLaoDongKhachSanNhaHang <> "" Then
                '    _workSheet.Cells("P20").PutValue(_TKSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("P20").PutValue("0")
                'End If
                '=====================================================================
                'Ăn uống
                Dim _TTAnUong As String = (From q In p Where q.Ten = "TTAnUong" Select q.GiaTri).FirstOrDefault
                If _TTAnUong <> 0 And _TTAnUong <> "" Then
                    _workSheet.Cells("Q14").PutValue(_TTAnUong)
                Else
                    _workSheet.Cells("Q14").PutValue("0")
                End If
                Dim _TTVoAnUong As String = (From q In p Where q.Ten = "TTVoAnUong" Select q.GiaTri).FirstOrDefault
                If _TTVoAnUong <> 0 And _TTVoAnUong <> "" Then
                    _workSheet.Cells("Q15").PutValue(CType(_TTVoAnUong / 1000000, Double))
                Else
                    _workSheet.Cells("Q15").PutValue("0")
                End If
                'Dim _TTSoLaoDongAnUong As String = (From q In p Where q.Ten = "TTSoLaoDongAnUong" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongAnUong <> 0 And _TTSoLaoDongAnUong <> "" Then
                '    _workSheet.Cells("Q16").PutValue(_TTSoLaoDongAnUong)
                'Else
                '    _workSheet.Cells("Q16").PutValue("0")
                'End If
                Dim _TKAnUong As String = (From q In p Where q.Ten = "TKAnUong" Select q.GiaTri).FirstOrDefault
                If _TKAnUong <> 0 And _TKAnUong <> "" Then
                    _workSheet.Cells("Q18").PutValue(_TKAnUong)
                Else
                    _workSheet.Cells("Q18").PutValue("0")
                End If
                Dim _TKVoAnUong As String = (From q In p Where q.Ten = "TKVoAnUong" Select q.GiaTri).FirstOrDefault
                If _TKVoAnUong <> 0 And _TKVoAnUong <> "" Then
                    _workSheet.Cells("Q19").PutValue(CType(_TKVoAnUong / 1000000, Double))
                Else
                    _workSheet.Cells("Q19").PutValue("0")
                End If
                'Dim _TKSoLaoDongAnUong As String = (From q In p Where q.Ten = "TKSoLaoDongAnUong" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongAnUong <> 0 And _TKSoLaoDongAnUong <> "" Then
                '    _workSheet.Cells("Q20").PutValue(_TKSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("Q20").PutValue("0")
                'End If
                '=====================================================================
                'thương nghiệp
                Dim _TTThuongNghiep As String = (From q In p Where q.Ten = "TTThuongNghiep" Select q.GiaTri).FirstOrDefault
                If _TTThuongNghiep <> 0 And _TTThuongNghiep <> "" Then
                    _workSheet.Cells("R14").PutValue(_TTThuongNghiep)
                Else
                    _workSheet.Cells("R14").PutValue("0")
                End If
                Dim _TTVoThuongNghiep As String = (From q In p Where q.Ten = "TTVoThuongNghiep" Select q.GiaTri).FirstOrDefault
                If _TTVoThuongNghiep <> 0 And _TTVoThuongNghiep <> "" Then
                    _workSheet.Cells("R15").PutValue(CType(_TTVoThuongNghiep / 1000000, Double))
                Else
                    _workSheet.Cells("R15").PutValue("0")
                End If
                'Dim _TTSoLaoDongThuongNghiep As String = (From q In p Where q.Ten = "TTSoLaoDongThuongNghiep" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongThuongNghiep <> 0 And _TTSoLaoDongThuongNghiep <> "" Then
                '    _workSheet.Cells("R16").PutValue(_TTSoLaoDongThuongNghiep)
                'Else
                '    _workSheet.Cells("R16").PutValue("0")
                'End If
                Dim _TKThuongNghiep As String = (From q In p Where q.Ten = "TKThuongNghiep" Select q.GiaTri).FirstOrDefault
                If _TKThuongNghiep <> 0 And _TKThuongNghiep <> "" Then
                    _workSheet.Cells("R18").PutValue(_TKThuongNghiep)
                Else
                    _workSheet.Cells("R18").PutValue("0")
                End If
                Dim _TKVoThuongNghiep As String = (From q In p Where q.Ten = "TKVoThuongNghiep" Select q.GiaTri).FirstOrDefault
                If _TKVoThuongNghiep <> 0 And _TKVoThuongNghiep <> "" Then
                    _workSheet.Cells("R19").PutValue(CType(_TKVoThuongNghiep / 1000000, Double))
                Else
                    _workSheet.Cells("R19").PutValue("0")
                End If
                'Dim _TKSoLaoDongThuongNghiep As String = (From q In p Where q.Ten = "TKSoLaoDongThuongNghiep" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongThuongNghiep <> 0 And _TKSoLaoDongThuongNghiep <> "" Then
                '    _workSheet.Cells("R20").PutValue(_TKSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("R20").PutValue("0")
                'End If
                '=====================================================================
                'mua bán
                Dim _TTMuaBan As String = (From q In p Where q.Ten = "TTMuaBan" Select q.GiaTri).FirstOrDefault
                If _TTMuaBan <> 0 And _TTMuaBan <> "" Then
                    _workSheet.Cells("S14").PutValue(_TTMuaBan)
                Else
                    _workSheet.Cells("S14").PutValue("0")
                End If
                Dim _TTVoMuaBan As String = (From q In p Where q.Ten = "TTVoMuaBan" Select q.GiaTri).FirstOrDefault
                If _TTVoMuaBan <> 0 And _TTVoMuaBan <> "" Then
                    _workSheet.Cells("S15").PutValue(CType(_TTVoMuaBan / 1000000, Double))
                Else
                    _workSheet.Cells("S15").PutValue("0")
                End If
                'Dim _TTSoLaoDongMuaBan As String = (From q In p Where q.Ten = "TTSoLaoDongMuaBan" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongMuaBan <> 0 And _TTSoLaoDongMuaBan <> "" Then
                '    _workSheet.Cells("S16").PutValue(_TTSoLaoDongMuaBan)
                'Else
                '    _workSheet.Cells("S16").PutValue("0")
                'End If
                Dim _TKMuaBan As String = (From q In p Where q.Ten = "TKMuaBan" Select q.GiaTri).FirstOrDefault
                If _TKMuaBan <> 0 And _TKMuaBan <> "" Then
                    _workSheet.Cells("S18").PutValue(_TKMuaBan)
                Else
                    _workSheet.Cells("S18").PutValue("0")
                End If
                Dim _TKVoMuaBan As String = (From q In p Where q.Ten = "TKVoMuaBan" Select q.GiaTri).FirstOrDefault
                If _TKVoMuaBan <> 0 And _TKVoMuaBan <> "" Then
                    _workSheet.Cells("S19").PutValue(CType(_TKVoMuaBan / 1000000, Double))
                Else
                    _workSheet.Cells("S19").PutValue("0")
                End If
                'Dim _TKSoLaoDongMuaBan As String = (From q In p Where q.Ten = "TKSoLaoDongMuaBan" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongMuaBan <> 0 And _TKSoLaoDongMuaBan <> "" Then
                '    _workSheet.Cells("S20").PutValue(_TKSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("S20").PutValue("0")
                'End If
                '=====================================================================
                'khác
                Dim _TTKhac As String = (From q In p Where q.Ten = "TTKhac" Select q.GiaTri).FirstOrDefault
                If _TTKhac <> 0 And _TTKhac <> "" Then
                    _workSheet.Cells("T14").PutValue(_TTKhac)
                Else
                    _workSheet.Cells("T14").PutValue("0")
                End If
                Dim _TTVoKhac As String = (From q In p Where q.Ten = "TTVoKhac" Select q.GiaTri).FirstOrDefault
                If _TTVoKhac <> 0 And _TTVoKhac <> "" Then
                    _workSheet.Cells("T15").PutValue(CType(_TTVoKhac / 1000000, Double))
                Else
                    _workSheet.Cells("T15").PutValue("0")
                End If
                'Dim _TTSoLaoDongKhac As String = (From q In p Where q.Ten = "TTSoLaoDongKhac" Select q.GiaTri).FirstOrDefault
                'If _TTSoLaoDongKhac <> 0 And _TTSoLaoDongKhac <> "" Then
                '    _workSheet.Cells("T16").PutValue(_TTSoLaoDongKhac)
                'Else
                '    _workSheet.Cells("T16").PutValue("0")
                'End If
                Dim _TKKhac As String = (From q In p Where q.Ten = "TKKhac" Select q.GiaTri).FirstOrDefault
                If _TKKhac <> 0 And _TKKhac <> "" Then
                    _workSheet.Cells("T18").PutValue(_TKKhac)
                Else
                    _workSheet.Cells("T18").PutValue("0")
                End If
                Dim _TKVoKhac As String = (From q In p Where q.Ten = "TKVoKhac" Select q.GiaTri).FirstOrDefault
                If _TKVoKhac <> 0 And _TKVoKhac <> "" Then
                    _workSheet.Cells("T19").PutValue(CType(_TKVoKhac / 1000000, Double))
                Else
                    _workSheet.Cells("T19").PutValue("0")
                End If
                'Dim _TKSoLaoDongKhac As String = (From q In p Where q.Ten = "TKSoLaoDongKhac" Select q.GiaTri).FirstOrDefault
                'If _TKSoLaoDongKhac <> 0 And _TKSoLaoDongKhac <> "" Then
                '    _workSheet.Cells("T20").PutValue(_TKSoLaoDongThongTinLienLac)
                'Else
                '    _workSheet.Cells("T20").PutValue("0")
                'End If
                '=====================================================================
                _workSheet.AutoFitColumns()
                Cls_Common.CreateDir(Server.MapPath("~/Template/ReportDownload/"))
                _workbook.Save(Server.MapPath("~/Template/ReportDownload/" & _fileName & ".xls"))
                Excute_Javascript("Alertbox('Xuất dữ liệu thành công'); SetDownFile('" & ResolveUrl("~/Template/ReportDownload/" & _fileName & ".xls") & "')", Me.Page, True)
            End Using
        Catch ex As Exception
            log4net.Config.XmlConfigurator.Configure()
            log.Error("Error error " & AddTabSpace(1) & Session("Username") & AddTabSpace(1) & "IP:" & GetIPAddress(), ex)
            Excute_Javascript("Alertbox('Xuất dữ liệu thất bại." & ex.Message & "');", Me.Page, True)
        End Try

    End Sub


End Class
